﻿namespace Sai.Core.Sandcastle
{
	using System.Collections.Generic;
	using System.IO;
	using Sai.Core.Reporting;

	internal class ReportIndexCollectionBuilder
	{
		public ReportIndexCollection Build(Project sandcastleProject)
		{
			return this.Build(sandcastleProject.Content);
		}

		public ReportIndexCollection Build(IEnumerable<string> files)
		{
			ReportIndexCollection collection = new ReportIndexCollection();

			foreach (string file in files)
			{
				if (File.Exists(file))
				{
					Identifier id = TopicIdReader.LoadFrom(file);

					collection.Add(new ReportIndex() { Guid = id.Value, Path = file });
				}
			}

			return collection;
		}
	}
}
